package uml.view;

import java.awt.BorderLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;
import javax.swing.JTextArea;

import uml.util.listeners.DragListener;
import uml.util.listeners.Dragable;

public class UMLContainerView
		extends JPanel
		implements Dragable, MouseListener
{

	private static final long serialVersionUID = 1L;
	private int numFields;

	public UMLContainerView ()
	{
		setLayout (new BorderLayout ());
		this.addMouseListener(this);
	}

	public void addDragListener (DragListener listener)
	{
		addMouseListener (listener);
		addMouseMotionListener (listener);
	}

	public void addFields (int numberOfFields)
	{
		JTextArea textArea;
		numFields = numberOfFields;
		for (int i = 0; i < numberOfFields; ++i)
		{
			textArea = new JTextArea ("Default Text");
			textArea.getBackground ();
			add (textArea);
		}
	}
	
	
	public void resize() {
		this.getParent().validate();
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		this.removeAll();
		addFields(++numFields);
		resize();
			
	}
	
	

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
